/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.vacoor.nothing.common.dataset.support.reader;

import org.vacoor.nothing.common.dataset.DatasetException;
import org.vacoor.nothing.common.dataset.RecordConsumer;
import org.vacoor.nothing.common.dataset.support.consumer.PrintRecordConsumer;
import org.vacoor.nothing.common.dataset.support.jxl.JxlReader;
import org.vacoor.nothing.common.util.IOUtils;

import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author vacoor
 */
public class JxlDatasetReader extends XlsReader {
    @Override
    public void read(BufferedInputStream is, final RecordConsumer consumer) throws DatasetException {
        JxlReader.use(consumer).read(is);
    }

    public static void main(String[] args) {
        CompoundReader reader = new CompoundReader();
        reader.addReader(new JxlDatasetReader());
        reader.addReader(new POIDatasetReader());

        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("test.xls");
        BufferedInputStream bis = IOUtils.toBuffered(is);

        reader.read(bis, new PrintRecordConsumer());
    }
}
